public class Helper{
 private int anchoVar;
 private int altoVar;
 private int posXVar;
 private int posYVar;
 private String textVar;
 private boolean visible;
 private int direccion;
 
 private int anchoFix;
 private int altoFix;
 private int posXFix;
 private int posYFix;
 private String textFix;
 
 private PFont font;
 private final int FONTSIZE=10;
 private PImage back;
 
 public Helper(int offset,int ancho,int offsety){
   font = loadFont("ComicSansMS-10.vlw");
   textFont(font,FONTSIZE);
  
   
  this.posXFix=offset;
  this.posYFix = height-offsety-15;
  this.anchoFix = width-ancho-offset;
  this.altoFix = FONTSIZE; 
  this.textFix = "";
  
  this.posXVar=-1;
  this.posYVar=-1;
  this.anchoVar=200;
  this.altoVar=FONTSIZE;
  this.textVar="";
  this.visible=false;
  this.direccion=1;
  
  back = loadImage("helper.png");
  }
 
 public void display(){
  //fill(255);
  //rect(posXFix,posYFix,anchoFix,altoFix); 
  image(back,0,posYFix-5,width,20);
  fill(255);
  text(textFix,posXFix,posYFix+altoFix);
  
  if(visible){
   if(mouseX+anchoVar > width){
    direccion=-1;  
  }
   else if(mouseX-anchoVar < 0){
     direccion=1;
   }
   fill(255);
  //rect(mouseX,mouseY,anchoVar*direccion,altoVar);
  
 
 char[] tmp = textVar.toCharArray();
 float ancho=0;
 for(int i=0;i<tmp.length;i++){
   ancho+=font.width(tmp[i])*10;
 }
 println(ancho);
 image(back,mouseX,mouseY+2,(ancho*direccion)+(20*direccion),altoVar);
 if(direccion==1){
text(textVar,mouseX,mouseY+altoVar); }
else{
  text(textVar,mouseX-ancho-10,mouseY+altoVar);
}
  }
  
 }
 
 public void setText(String t){
   this.textFix = t;
 }
 public void setTextVar(String t){
   this.textVar=t;
 }
 
 public void setVisible(boolean bol){
   this.visible=bol;
 }
}
